<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:rich="http://richfaces.org/rich"       
    xmlns:s="http://jboss.com/products/seam/taglib">

  <ui:composition template="template.xhtml">
  
    <ui:define name="head">
      <link href="style/security.css" rel="stylesheet" type="text/css"/>
    </ui:define>  
   
    <ui:define name="content">
        
      <div id="contentMain">

  	    <h2>User Details</h2>  
  	    
  	    <h:messages globalOnly="true"/>
  	    
  	    <h:form id="user">
  	    
          <div class="formRow">
            <h:outputLabel for="firstname" value="First name" styleClass="formLabel"/>
            <h:inputText id="firstname" value="#{userAction.firstname}" readonly="#{identityManager.userExists(userAction.username)}"/>
            <div class="validationError"><h:message for="firstname"/></div>
          </div>  
          
          <div class="formRow">
            <h:outputLabel for="lastname" value="Last name" styleClass="formLabel"/>
            <h:inputText id="lastname" value="#{userAction.lastname}" readonly="#{identityManager.userExists(userAction.username)}"/>
            <div class="validationError"><h:message for="lastname"/></div>
          </div>            
              
          <div class="formRow">
            <h:outputLabel for="username" value="Username" styleClass="formLabel"/>
            <h:inputText id="username" value="#{userAction.username}" readonly="#{identityManager.userExists(userAction.username)}"/>
            <div class="validationError"><h:message for="username"/></div>
          </div>              

          <div class="formRow">
            <h:outputLabel for="password" value="Password" styleClass="formLabel"/>
            <h:inputSecret id="password" value="#{userAction.password}"/>
            <div class="validationError"><h:message for="password"/></div>
          </div>              
          
          <div class="formRow">
            <h:outputLabel for="confirm" value="Confirm password" styleClass="formLabel"/>
            <h:inputSecret id="confirm" value="#{userAction.confirm}"/>
          </div>                        
              
          <div class="formRow">            
            <h:outputLabel for="roles" value="Member of" styleClass="formLabel"/>
            <div class="selectMany">
              <h:selectManyCheckbox id="roles" value="#{userAction.roles}" layout="pageDirection" styleClass="roles">
                <s:selectItems value="#{identityManager.listGrantableRoles()}" var="role" label="#{role}"/>
              </h:selectManyCheckbox>
            </div>
            <div class="validationError"><h:message for="roles"/></div>            
          </div>
          
          <div class="formRow">
            <h:outputLabel for="enabled" value="Account enabled" styleClass="formLabel"/>
            <h:selectBooleanCheckbox id="enabled" value="#{userAction.enabled}"/>
          </div>   
                                      
          <div class="formButtons">
            <h:commandButton id="save" value="Save" action="#{userAction.save}" styleClass="formButton"/>
            <s:button id="cancel" view="/usermanager.xhtml" value="Cancel" propagation="end" styleClass="formButton"/>
          </div>
    
          <br class="clear"/>
  	    
  	    </h:form>

	    </div>
	    
    </ui:define>
    
  </ui:composition>
</html>
